package com.itheima.Demo01.demo03;

import java.util.Comparator;
import java.util.TreeSet;

public class Test01 {
    public static void main(String[] args) {
        TreeSet<Student> set = new TreeSet<>((o1, o2) -> {
            int i = o1.getAge() - o2.getAge();
            int i1 = i == 0 ? o1.getName().compareTo(o2.getName()):i;
            return i1;
        });


        Student s1 = new Student("abddasdasdasdsadc",60);
        Student s2 = new Student("agdsadd",30);
        Student s3 = new Student("bfsafsafsaas",30);
        Student s4 = new Student("bds",40);
        Student s5 = new Student("cafdsaddsa",30);
        Student s6 = new Student("cafdsasafg",41);
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        set.add(s5);
        set.add(s6);


        System.out.println(set);
    }
}
